package cn.sgjk.train.business.controller.admin;


import cn.sgjk.train.common.context.LoginMemberContext;
import cn.sgjk.train.common.resp.CommonResp;
import cn.sgjk.train.common.resp.PageResp;
import cn.sgjk.train.business.req.TrainStationQueryReq;
import cn.sgjk.train.business.req.TrainStationSaveReq;
import cn.sgjk.train.business.resp.TrainStationQueryResp;
import cn.sgjk.train.business.service.TrainStationService;
import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/train-station")
public class TrainStationAdminController {

    private static final Logger LOG = LoggerFactory.getLogger(TrainStationAdminController.class);
    @Autowired
    private TrainStationService trainStationService;



    @PostMapping("/save")
    public CommonResp<Object> save(@Valid @RequestBody TrainStationSaveReq trainStationReq) {
        trainStationService.save(trainStationReq);
        return new CommonResp<>();
    }



    @GetMapping("/query-list")
    public CommonResp<PageResp<TrainStationQueryResp>> query(@Valid TrainStationQueryReq trainStationQueryReq) {
        PageResp<TrainStationQueryResp> trainStationQueryResps = trainStationService.queryList(trainStationQueryReq);
        return new CommonResp<>(trainStationQueryResps);
    }

    @DeleteMapping("/delete/{id}")
    public CommonResp<Object> delete(@PathVariable Long id) {
        trainStationService.delete(id);
        return new CommonResp<>();
    }
}

